import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yinshui_caiying/utils/colors.dart';
import 'package:yinshui_caiying/widgets/border_dashed.dart';
import 'package:yinshui_caiying/widgets/picker/models/pickerItem_model.dart';
import 'package:yinshui_caiying/widgets/picker/pickers.dart';

class FormSinglePicker extends StatelessWidget {
  String title;
  dynamic Function(PickerItemModel) onConfirm;
  List<PickerItemModel> dataList;
  Rx<PickerItemModel> value;
  bool hasBorder;

  FormSinglePicker(
      {required this.title,
      required this.onConfirm,
      required this.dataList,
      required this.value,
      this.hasBorder = true});

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
        onTap: () {
          Pickers.showSinglePicker(
              data: dataList,
              selectData: value.value,
              onConfirm: onConfirm,
              title: title);
        },
        child: Column(children: [
          Container(
              width: 1.sw,
              height: 147.h,
              child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      title,
                      style: TextStyle(
                        fontSize: 40.sp,
                        fontWeight: FontWeight.w400,
                      ),
                    ),
                    Expanded(
                        flex: 1,
                        child: Row(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: [
                              Obx(() => Text(value.value.name,
                                  textAlign: TextAlign.right,
                                  style: TextStyle(
                                    // color: Color.fromRGBO(193, 192, 192, 1),
                                    fontSize: 40.sp,
                                    fontWeight: FontWeight.w400,
                                  ))),
                              Container(
                                  height: 60.w,
                                  width: 60.w,
                                  child: IconButton(
                                    padding: EdgeInsets.all(0),
                                    alignment: Alignment.centerRight,
                                    icon: Icon(
                                      Icons.expand_more,
                                      color: Color.fromRGBO(204, 204, 204, 1),
                                      size: 60.w,
                                    ),
                                    onPressed: null,
                                  ))
                            ]))
                  ])),
          hasBorder ? MySeparator() : Container()
        ]));
  }
}
